package com.beta.cust.bind.datasync.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.beta.cust.bind.datasync.constant.BusinessConstant;
import com.beta.cust.bind.datasync.mapper.DepartmentInfoMapper;
import com.beta.cust.bind.datasync.mapper.EmpDepRefMapper;
import com.beta.cust.bind.datasync.mapper.entity.EmpDepRef;
import com.beta.cust.bind.datasync.service.IEmpDepRefService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * <p>
 * 员工信息-部门信息关联表 服务实现类
 * </p>
 *
 * @author pcc
 * @since 2024-03-12
 */
@Service
public class EmpDepRefServiceImpl extends ServiceImpl<EmpDepRefMapper, EmpDepRef> implements IEmpDepRefService {
    @Autowired
    private DepartmentInfoMapper departmentInfoMapper;

    @Override
    public void delByDepIds(List<Long> delDepartmenIdList) {
        if (CollectionUtils.isEmpty(delDepartmenIdList)) {
            return;
        }
        EmpDepRef updateEmfDepRef = new EmpDepRef();
        updateEmfDepRef.setDelFlag(BusinessConstant.IS_DEL_FLAG);
        LambdaQueryWrapper updateCondition = new LambdaQueryWrapper<EmpDepRef>()
                .in(EmpDepRef::getDepId, delDepartmenIdList);
        getBaseMapper().update(updateEmfDepRef, updateCondition);
    }

    @Override
    public void updateDelByDepIdAndEnterpriseId(List<Long> delDepartmenIdList, String enterpriseId, String delflag) {
        departmentInfoMapper.updateDelByDepIdAndEnterpriseId(delDepartmenIdList, enterpriseId, delflag);
    }

    @Override
    public void updateDelByUseridAndEnterpriseIdAndDepartmentId(List<String> delDepartmentEmployeeUseridList, String enterpriseId, Long departmentId) {
        departmentInfoMapper.updateDelByUseridAndEnterpriseIdAndDepartmentId(delDepartmentEmployeeUseridList, enterpriseId, departmentId);
    }

}
